package com.songcha.module_mine.ui.fragment.setting.bind_phone

import android.content.Intent
import android.os.Bundle
import android.telephony.PhoneNumberUtils
import android.view.View
import com.songcha.library_base.base.BaseFragment
import com.songcha.library_business.proxy.userinfo.UserInfoManager
import com.songcha.library_common.util.StringUtil
import com.songcha.library_common.util.ToastUtil
import com.songcha.module_mine.R
import com.songcha.module_mine.databinding.MineFragmentBindPhoneBinding
import com.songcha.module_mine.ui.activity.bind_phone.BindPhoneActivity

class SettingBindPhoneFragment:BaseFragment() {
    init{
        TAG=SettingBindPhoneFragment::class.java.simpleName
    }

    private lateinit var binding:MineFragmentBindPhoneBinding

    override fun getRootView(): View? {
        binding=MineFragmentBindPhoneBinding.inflate(layoutInflater)
        return binding.root
    }

    /*override fun getLayoutId(): Int {
        return R.layout.mine_fragment_bind_phone
    }*/

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)

        if(UserInfoManager.checkLogin()){
            binding.mineTvBindPhone.text=StringUtil.hidePhoneMiddleNumber(UserInfoManager.userInfo!!.phonenumber)
        }

        binding.mineBtnModifyBindPhone.setOnClickListener {
            if(UserInfoManager.userInfo!!.registeredSource!=1) {
                ToastUtil.show("微信登录不能修改绑定手机")
                return@setOnClickListener
            }
            val intent= Intent(it.context, BindPhoneActivity::class.java)
            intent.putExtra("is_change",true)
            startActivity(intent)
        }

    }

    override fun onResume() {
        super.onResume()
        if(UserInfoManager.checkLogin()){
            binding.mineTvBindPhone.text=StringUtil.hidePhoneMiddleNumber(UserInfoManager.userInfo!!.phonenumber)
        }
    }
}